<template>
	<view class="content">
		<image mode="widthFix" style="width: 100%;" :src="imageUrl+'/job_hunting/index/bg.png'" class="bg-img"></image>
		<view class="welcome-box">
			<view class="welcome-text">Welcome</view>
			<view class="welcome-text" style="font-size:54rpx;font-weight:bold;">进入就业帮帮我</view>
		</view>
		<view class="theme">
			<view class="agreement-block">
				<checkbox-group @change="checkChange">
					<checkbox color="#FF7626" id="check" class="checkbox" checked="checked"/><label for="check"
						class="radio-label">我已阅读并同意<text class="agreement">
							《用户服务协议》</text><text class="agreement">《个人信息保护政策》</text>，未注册的手机号将自动完成注册</label>
				</checkbox-group>
			</view>
			<view>
				<button size="mini" type="primary" class="entrance1" open-type="getPhoneNumber"
					@getphonenumber="getPhoneNumber">微信快捷登录</button>
			</view>
			<view @click="navigate('/page_other/login/index')" class="entrance2">
				手机号登录
			</view>

		</view>

	</view>
</template>

<script>
	import {
		isLogin
	} from '@/util/user.js';
	import {getStorage} from '@/util/auth.js'
	export default {
		data() {
			return {
				imageUrl: '',
				form: {
					checked: [],
					type: '',
					phoneInfo: ''
				},
				rules: {
					checked: {
						name: '',
						required: false,
						validator: function(value, form, callback) {
							if (value.length == 0) {
								callback('请勾选同意协议！');
							}
							callback();
						}
					},
				},
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			/**
			 *
			 * 获取用户信息
			 */
			userLogin() {
				uni.login({
					provider: 'weixin',
					success: async (res) => {
						// console.log('登录获取code', res.code);
						if (res.errMsg == 'login:ok') {
							this.userCode = res.code;
							console.log(this.userCode);
			
						}
					},
				});
			},
			getPhoneNumber(e) {
				this.form.phoneInfo = e.detail.code;
				if(this.form.phoneInfo)
				{
					uni.showLoading({
						title:'提交中',
						mask:true,
					})
					this.form.type=this.$store.getters.identity;
					this.$store.dispatch('user/login',this.form).then(()=>{
						uni.showLoading({
							title:'登录中',
							mask:true
						})
						this.$store.dispatch('user/loginIM').then(()=>{
							const user=this.$store.getters.user;
							if(getStorage('identity')==2&&user.authenticationStatus==3){
									uni.navigateTo({
										url:'/page_other/enterprise/authorization/examine'
									})
							}else{
								this.showToast('登录成功',()=>{
									uni.switchTab({
										url:'/pages/mine/index'
									})
								});
							}
						})
					})
				}
			}

		},
		onLoad() {
			this.imageUrl = this.globalConfig.imageUrl;
			if (isLogin()) { //如果已经登录则跳转至首页
				uni.switchTab({
					url: '/pages/home/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #FAFAFA;
	}

	.content .bg-img {
		width: 100%;
		position: absolute;
		top: 0;
	}

	.content .welcome-box {
		width: 85%;
		padding: 30rpx 0 0 7.5%;
		position: relative;

		.welcome-text {
			font-size: 36rpx;
			color: #fff;
			padding: 10rpx 0;
		}
	}



	.content .theme {
		margin-top: 100rpx;
		background: #fff;
		width: 100%;
		position: absolute;
		border-radius: 50rpx;

		.agreement-block {
			width: 100%;
			margin-top: 40rpx;
			display: flex;
			flex-direction: row;
			padding: 30rpx;

			.radio-label {
				font-size: 24rpx;

				.agreement {
					color: #FB093B;
				}
			}

			.checkbox {
				transform: scale(0.7);
			}
		}

		.entrance1 {
			width: 75%;
			height: 100rpx;
			margin: 50rpx auto;
			background-color: #fff;
			border-radius: 36rpx;
			background-color: #FB093B;
			color: #fff;
			overflow: hidden;
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			align-items: center;
			position: relative;
		}

		.entrance2 {
			width: 75%;
			height: 100rpx;
			margin: 5rpx auto;
			// background-color: #fff;
			border-radius: 36rpx;
			border: 1rpx solid #999;
			// box-shadow: 0px 0px 4px #ccc;
			overflow: hidden;
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			align-items: center;
			position: relative;
		}
	}
</style>
